

void UI_LineRelAngleOptions::setAction(PF_ActionInterface* a, bool update) {
    if (a!=NULL && a->rtti()==LX_Define::ActionDrawLineRelAngle) {
        action = (WF_DrawLineRelAngle*)a;
        if (action->hasFixedAngle()) {
            lAngle->setDisabled(true);
            leAngle->setDisabled(true);
        }

        QString sa;
        QString sl;

        // settings from action:
        if (update) {
            sa = QString("%1").arg(PF_Math::rad2deg(action->getAngle()));
            sl = QString("%1").arg(action->getLength());
        }
        // settings from config file:
        else {
            PF_SETTINGS->beginGroup("/Draw");
            if (!action->hasFixedAngle()) {
                sa = PF_SETTINGS->readEntry("/LineRelAngleAngle", "30.0");
            } else {
                sa = QString("%1").arg(PF_Math::rad2deg(action->getAngle()));
            }
            sl = PF_SETTINGS->readEntry("/LineRelAngleLength", "10.0");
            PF_SETTINGS->endGroup();
        }

        leAngle->setText(sa);
        leLength->setText(sl);
    } else {
        PF_DEBUG->print(PF_Debug::D_ERROR, 
			"UI_LineRelAngleOptions::setAction: wrong action type");
        this->action = NULL;
    }
}

void UI_LineRelAngleOptions::destroy() {
    if (action!=NULL) {
        PF_SETTINGS->beginGroup("/Draw");
        if (!action->hasFixedAngle()) {
            PF_SETTINGS->writeEntry("/LineRelAngleAngle", 
				PF_Math::rad2deg(action->getAngle()));
        }
        PF_SETTINGS->writeEntry("/LineRelAngleLength", action->getLength());
        PF_SETTINGS->endGroup();
    }
}

void UI_LineRelAngleOptions::updateAngle(const QString& a) {
    if (action!=NULL && !action->hasFixedAngle()) {
        action->setAngle(PF_Math::deg2rad(PF_Math::eval(a)));
    }
}

void UI_LineRelAngleOptions::updateLength(const QString& l) {
    if (action!=NULL) {
        action->setLength(PF_Math::eval(l));
    }
}
